/*
 * Teknei 2014 - All rights reserved
 */
package com.teknei.acabus.core.entities;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * The persistent class for the "NAVIGATION_PARENT" database table.
 * @author Jorge Amaro
 * @version 1.0
 * @since 1.0
 */
/**
 * @author amaro
 *
 */
@Entity
@Table(name = "\"SITM_NAVIGATION_PARENT\"")
@NamedQuery(name = "NavigationParent.findAll", query = "SELECT n FROM NavigationParent n")
public class NavigationParent implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name = "\"NAVIGATION_PARENT_IDPARENT_GENERATOR", sequenceName = "\"NAVIGATION_PARENT_id_parent_seq\"")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "\"NAVIGATION_PARENT_IDPARENT_GENERATOR")
	@Column(name = "id_parent", unique = true, nullable = false)
	private Integer idParent;

	private String outcome;

	private String text;

	private String url;

	private int root;

	// bi-directional many-to-one association to NavigationChild
	@OneToMany(mappedBy = "navigationParent")
	private List<NavigationChild> navigationChilds;

	// bi-directional many-to-one association to NavigationParentRole
	@OneToMany(mappedBy = "parent", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
	private List<NavigationParentRole> navigationParentRoles;

	/**
	 * 
	 */
	public NavigationParent() {
	}

	/**
	 * @return
	 */
	public Integer getIdParent() {
		return this.idParent;
	}

	/**
	 * @param idParent
	 */
	public void setIdParent(Integer idParent) {
		this.idParent = idParent;
	}

	/**
	 * @return
	 */
	public String getOutcome() {
		return this.outcome;
	}

	/**
	 * @param outcome
	 */
	public void setOutcome(String outcome) {
		this.outcome = outcome;
	}

	/**
	 * @return
	 */
	public String getText() {
		return this.text;
	}

	/**
	 * @param text
	 */
	public void setText(String text) {
		this.text = text;
	}

	/**
	 * @return
	 */
	public List<NavigationChild> getNavigationChilds() {
		return this.navigationChilds;
	}

	/**
	 * @param navigationChilds
	 */
	public void setNavigationChilds(List<NavigationChild> navigationChilds) {
		this.navigationChilds = navigationChilds;
	}

	/**
	 * @param navigationChild
	 * @return
	 */
	public NavigationChild addNavigationChild(NavigationChild navigationChild) {
		getNavigationChilds().add(navigationChild);
		navigationChild.setNavigationParent(this);

		return navigationChild;
	}

	/**
	 * @param navigationChild
	 * @return
	 */
	public NavigationChild removeNavigationChild(NavigationChild navigationChild) {
		getNavigationChilds().remove(navigationChild);
		navigationChild.setNavigationParent(null);

		return navigationChild;
	}

	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * @param url
	 *            the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}

	/**
	 * @return the root
	 */
	public int getRoot() {
		return root;
	}

	/**
	 * @param root
	 *            the root to set
	 */
	public void setRoot(int root) {
		this.root = root;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "NavigationParent [idParent=" + idParent + ", outcome="
				+ outcome + ", text=" + text + ", url=" + url + ", root="
				+ root + "]";
	}

	/**
	 * @return the navigationParentRoles
	 */
	public List<NavigationParentRole> getNavigationParentRoles() {
		return navigationParentRoles;
	}

	/**
	 * @param navigationParentRoles
	 *            the navigationParentRoles to set
	 */
	public void setNavigationParentRoles(
			List<NavigationParentRole> navigationParentRoles) {
		this.navigationParentRoles = navigationParentRoles;
	}

}